import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ScrollBarEx extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Scrollbar 示例'),),
      body: ScrollBarEx2(),
    );
  }
}

class ScrollBarEx1 extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scrollbar(child: GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
        itemBuilder: (BuildContext context, int index){
      return Center(child: Text('item $index'),);
        },
    itemCount: 120,));
  }
}

//scrollbar一直显示
class ScrollBarEx2 extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return _ScrollBarEx2();
  }
}

class _ScrollBarEx2 extends State<ScrollBarEx2>{
  final ScrollController _controllerOne = ScrollController();
  @override
  Widget build(BuildContext context) {
    return Scrollbar(child: GridView.builder(gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
        itemBuilder: (BuildContext context, int index){
      return Center(
        child: Text('item $index'),
      );
        },itemCount: 120,),
    isAlwaysShown: true,);
  }
}
